using Unity.Burst;
using Unity.Entities;

partial struct EnemySystem : ISystem
{
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        EnemyJob enemyJob = new EnemyJob
        {
            player = SystemAPI.GetSingleton<Player>(),
        };
        enemyJob.ScheduleParallel();
        //Player player = SystemAPI.GetSingleton<Player>();
        //foreach((
        //    RefRW<Enemy> enemy, 
        //    RefRW<Mover> mover) 
        //    in SystemAPI.Query<
        //        RefRW<Enemy>, 
        //        RefRW<Mover>>())
        //{
        //    mover.ValueRW.targetPos = player.curPos;
        //}
    }
}

[BurstCompile]
public partial struct EnemyJob : IJobEntity
{
    public Player player;
    public void Execute(ref Enemy enemy, ref Mover mover)
    {
        mover.targetPos = player.curPos;
    }
}
